#include "sdkGlobal.h"
#include "platform_global.h"
#include "platform_trans.h"


typedef struct
{
    InputAmountFunc mInputAmountFunc;
    ReadCardFunc mReadCardFunc;
    ConfirmCardNOFunc mConfirmCardNoFunc;
    InputCardPasswordFunc mInputCardPwdFunc;
    RecordPlatformFunc mRecordPlatformFunc;
    TransmitDataPlatformFunc mTransmitDataPlatformFunc;
    UpdateTransEntityFunc mUpdateTransEntityFunc;
    OnlineLoginFunc mOnlineLoginFunc;
    UnKnownTransAttrFunc mUnKnownTransAttrFunc;
    DisplayReadCardViewFunc mDisplayReadCardViewFun;
    ShowEmvFlow2FailFunc mShowEmvFlow2FailFunc;
    CalcStatisticsInfoFunc mCalcStatisticsInfoFunc;
} platform_trans_entity;

static platform_trans_entity g_platform_trans_entity;

void platform_trans_init()
{
    memset(&g_platform_trans_entity, 0x00, sizeof(platform_trans_entity));
}

void platform_trans_set_input_amount_func(InputAmountFunc func)
{
    g_platform_trans_entity.mInputAmountFunc = func;
}

InputAmountFunc platform_trans_get_input_amount_func()
{
    return g_platform_trans_entity.mInputAmountFunc;
}

void platform_trans_set_read_card_func(ReadCardFunc func)
{
    g_platform_trans_entity.mReadCardFunc = func;
}

ReadCardFunc platform_trans_get_read_card_func()
{
    return g_platform_trans_entity.mReadCardFunc;
}

void platform_trans_set_confirm_card_no_func(ConfirmCardNOFunc func)
{
    g_platform_trans_entity.mConfirmCardNoFunc = func;
}

ConfirmCardNOFunc platform_trans_get_confirm_card_no_func()
{
    return g_platform_trans_entity.mConfirmCardNoFunc;
}

void platform_trans_set_input_card_pwd_func(InputCardPasswordFunc func)
{
    g_platform_trans_entity.mInputCardPwdFunc = func;
}

InputCardPasswordFunc platform_trans_get_input_card_pwd_func()
{
    return g_platform_trans_entity.mInputCardPwdFunc;
}

void platform_trans_set_record_func(RecordPlatformFunc *flowFunc)
{
    memcpy(&g_platform_trans_entity.mRecordPlatformFunc, flowFunc, sizeof(RecordPlatformFunc));
}

RecordPlatformFunc *platform_trans_get_record_func()
{
    return &g_platform_trans_entity.mRecordPlatformFunc;
}

void platform_trans_set_transmit_data_func(TransmitDataPlatformFunc *platformFunc)
{
    memcpy(&g_platform_trans_entity.mTransmitDataPlatformFunc, platformFunc, sizeof(TransmitDataPlatformFunc));
}

TransmitDataPlatformFunc *platform_trans_get_transmit_data_func()
{
    return &g_platform_trans_entity.mTransmitDataPlatformFunc;
}

void platform_trans_set_update_trans_entity_func(UpdateTransEntityFunc func)
{
    g_platform_trans_entity.mUpdateTransEntityFunc = func;
}

UpdateTransEntityFunc platform_trans_get_update_trans_entity_func()
{
    return g_platform_trans_entity.mUpdateTransEntityFunc;
}

void platform_trans_set_online_login_func(OnlineLoginFunc func)
{
    g_platform_trans_entity.mOnlineLoginFunc = func;
}

OnlineLoginFunc platform_trans_get_online_login_func()
{
    return g_platform_trans_entity.mOnlineLoginFunc;
}

void platform_trans_set_unknown_trans_attr_func(UnKnownTransAttrFunc func)
{
    g_platform_trans_entity.mUnKnownTransAttrFunc = func;
}

UnKnownTransAttrFunc platform_trans_get_unknown_trans_attr_func()
{
    return g_platform_trans_entity.mUnKnownTransAttrFunc;
}

void platform_trans_set_display_readcard_view_func(DisplayReadCardViewFunc func)
{
    g_platform_trans_entity.mDisplayReadCardViewFun = func;
}

DisplayReadCardViewFunc platform_trans_get_display_readcard_view_func()
{
    return g_platform_trans_entity.mDisplayReadCardViewFun;
}

void platform_trans_set_show_emv_flow2_fail_func(ShowEmvFlow2FailFunc func)
{
    g_platform_trans_entity.mShowEmvFlow2FailFunc = func;
}

ShowEmvFlow2FailFunc platform_trans_get_show_emv_flow2_fail_func()
{
    return g_platform_trans_entity.mShowEmvFlow2FailFunc;
}

void platform_trans_set_calc_statistics_info_func(CalcStatisticsInfoFunc func)
{
    g_platform_trans_entity.mCalcStatisticsInfoFunc = func;
}

CalcStatisticsInfoFunc platform_trans_get_calc_statistics_info_func()
{
    return g_platform_trans_entity.mCalcStatisticsInfoFunc;
}
